package com.dgut.edu.cn.design.mode.filterchain.dto;

import lombok.Data;

/**
 * @description:
 * @author: hongbin.zheng
 * @create: 2023-08-10 18:42
 **/
@Data
public class RuleFilterResVo {
	/**
	 * 过滤结果
	 */
	private boolean isFilter;
	/**
	 * 响应状态码
	 */
	private Integer msgCode;
	/**
	 * 响应数据
	 */
	private Object msg;
	/**
	 * 过滤器名称
	 */
	private String ruleFilterName;


	/**
	 * 响应不过滤信息
	 * @param ruleFilterName
	 * @return
	 */
	public static RuleFilterResVo ok(String ruleFilterName) {
		RuleFilterResVo ruleFilterResVo = new RuleFilterResVo();
		ruleFilterResVo.setFilter(false);
		ruleFilterResVo.setMsgCode(200);
		ruleFilterResVo.setRuleFilterName(ruleFilterName);
		ruleFilterResVo.setMsg(null);
		return ruleFilterResVo;
	}

	/**
	 * 响应过滤信息
	 * @param msg
	 * @param ruleFilterName
	 * @return
	 */
	public static RuleFilterResVo fail(Object msg, String ruleFilterName) {
		RuleFilterResVo ruleFilterResVo = new RuleFilterResVo();
		ruleFilterResVo.setFilter(true);
		ruleFilterResVo.setMsgCode(200);
		ruleFilterResVo.setRuleFilterName(ruleFilterName);
		ruleFilterResVo.setMsg(msg);
		return ruleFilterResVo;
	}
}
